package com.ylz.sjzx.sio.room.adapter;

import com.ylz.sjzx.sio.common.core.enums.Cmd;
import com.ylz.sjzx.sio.common.core.enums.MessageType;
import com.ylz.sjzx.sio.common.core.core.container.common.annotation.AdapterDesc;
import com.ylz.sjzx.sio.sdk.client.core.AbstractBaseAdapter;
import com.ylz.sjzx.sio.sdk.client.session.IMSession;
import com.ylz.sjzx.sio.sdk.client.utils.ChatRoomMessageUtil;
import com.ylz.sjzx.sio.sdk.model.BaseSocketModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * 学生抢答
 *
 * @author JZJY
 * @version 1.0
 * @date 2020/12/16
 */
@Component
@AdapterDesc(id = "allowAnswer")
public class AllowAnswerAdapter extends AbstractBaseAdapter {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public void process() {
        IMSession session = this.getSession();
        List list = (List) this.getParam();
        Map map = (Map) list.get(0);
        BaseSocketModel baseSocketModel = BaseSocketModel.builder().action(Cmd.allowAnswer).
                param(map).needtoParam(true).build();
        ChatRoomMessageUtil.sendMessage(session, MessageType.ALL, baseSocketModel);
    }
}
